﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Upreader.Usenet.Nntp
{
    public class NntpClientStatistics : INntpStatisticsSource
    {
        #region Fields

        private long _totalBytesSent;
        private long _totalBytesReceived;

        #endregion // Fields

        #region Properties

        /// <summary>
        /// Reads the total bytes sent in an interlocked fashion
        /// </summary>
        public long TotalBytesSent
        {
            get { return Interlocked.Read(ref _totalBytesSent); }
        }

        /// <summary>
        /// Reads the total bytes received in an interlocked fashion
        /// </summary>
        public long TotalBytesReceived
        {
            get { return Interlocked.Read(ref _totalBytesReceived); }
        }

        #endregion // Properties

        #region Methods

        void INntpStatisticsSource.UpdateTotalBytesSent(long delta)
        {
            Interlocked.Add(ref _totalBytesSent, delta);
        }

        void INntpStatisticsSource.UpdateTotalBytesReceived(long delta)
        {
            Interlocked.Add(ref _totalBytesReceived, delta);
        }

        #endregion // Methods
    }
}
